package com.sk.bilibili.model.fragment.live;

import com.sk.api.annotations.Autowired;
import com.sk.bilibili.bean.Live;
import com.sk.bilibili.callBack.RequestCallBack;
import com.sk.bilibili.mapper.LiveMapper;
import com.sk.bilibili.model.BaseModel;
import com.sk.bilibili.model.BaseRefreshModel;
import com.sk.bilibili.utils.RequestUtils;
import com.sk.bilibili.view.fragment.live.RecommendFragment;

import java.util.List;

public class RecommendModel extends BaseRefreshModel<RecommendFragment> {

    @Autowired
    LiveMapper liveMapper;
    private int page=1;

    public void loadMore(Integer typeId) {
        RequestUtils.process(liveMapper.getTypeLivePage(page, typeId), lives -> {
            view.addLive(lives);
            page++;
        });
    }

    public void refresh(Integer typeId) {
        page=1;
        RequestUtils.process(liveMapper.getTypeLivePage(page, typeId), lives -> {
            view.setLive(lives);
            page++;
        });
    }

}